/*function initPop(obj) {
	var pop = $('#myModal');
	obj.title = '<div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title" id="myModalLabel">' + obj.title + '</h4></div>';
	obj.content = (obj.content != "" && obj.content != undefined) ? '<div class="modal-body">' + obj.content + '</div>' : "";
	obj.button = '<div class="modal-footer"><button type="button" class="btn btn-default" data-dismiss="modal">Close</button><button type="button" class="btn btn-primary">Submit</button></div>';
	pop.find(".modal-content").html(obj.title + obj.content + obj.button);
	if(obj.submit != undefined) {
		pop.find(".modal-content button:last-child").click(function() {
			obj.submit(obj.id);
			pop.modal('hide');
		});
	}
	pop.modal('toggle');
}
*/
;
(function(root, factory) {
	if(typeof define === 'function' && define.amd) {
		// AMD. Register as an anonymous module.
		define([], factory);
	} else if(typeof module === 'object' && module.exports) {
		// Node. Does not work with strict CommonJS, but
		// only CommonJS-like environments that support module.exports,
		// like Node.
		module.exports = factory();
	} else {
		// Browser globals (root is window)
		root['Popup'] = factory();
	}
}(this, function() {
	'use strict';
	var Popup = function(opts) {
		var _generateId = function() {
			var id = Math.ceil(Math.random() * 9999);
			while(id.length < 4) {
				id = "0" + id;
			}
			return id;
		}

		// define property
		opts = opts || {};
		this.title = opts.title || '';
		this.content = opts.content || '';
		this.footer = opts.footer || '';
		this.data = opts.data || {};
		this.container = document.querySelector(opts.container || "body");
		this.modal = undefined;
		this.submit = opts.submit || function() {};
		//this.modal = document.querySelector(opts.pop);
		this.id = opts.id || "modal" + _generateId();

		this._generateContainer();
	};

	Popup.prototype.show = function() {
		$(this.modal).modal('show');
	}

	Popup.prototype.hide = function() {
		$(_pop).modal('hide');
	}

	Popup.prototype.id = function() {
		return this.id
	}
	
	Popup.prototype._generateContainer = function() {
			this.modal = document.createElement("div");
			this.modal["aria-hidden"] = true;
			this.modal.role = dialog;
			this.modal.className = "modal fade";
			this.modal.id = this.id;

			var dialog = document.createElement("div");
			dialog.className = "modal-dialog";

			var content = document.createElement("div");
			content.className = "modal-content col-sm-12";
			var _title = '<div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title" id="myModalLabel">' + this.title + '</h4></div>';
			var _content = (this.content != "" && this.content != undefined) ? '<div class="modal-body">' + this.content + '</div>' : "";
			var _footer = '<div class="modal-footer">' + this.footer + '</div>';
			content.innerHTML = _title + _content + _footer;

			dialog.appendChild(content);
			this.modal.appendChild(dialog);
		}

	return Popup;
}));